package cn.lfy.studentmanager.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.lfy.studentmanager.dao.ClbumDao;
import cn.lfy.studentmanager.dao.DepartmentDao;
import cn.lfy.studentmanager.domain.Clbum;
import cn.lfy.studentmanager.domain.Department;
import cn.lfy.studentmanager.service.ClbumService;

//此处注意要使用注解，这样才知道用到前面的service接口
@Service
public class ClbumServiceImpl implements ClbumService{
//这就是service接口实现类
	//注解注入dao,service调用dao，dao才是真正操作数据库的
	@Autowired
	private ClbumDao clbumDao;
	@Autowired
	private DepartmentDao departmentDao;
	
	@Override
	public boolean add(Clbum clbum) {
		// TODO Auto-generated method stub
		return clbumDao.add(clbum);
	}
	@Override
	public List<Map<String, Object>> select(int page, int limit) {
		return clbumDao.select((page-1)*limit,limit);
	}
	@Override
	public boolean delete(int id) {
		boolean isSuccess;
		try {
			isSuccess = clbumDao.delete(id);
		} catch (Exception e) {
			return false;
		}
		return isSuccess;
		//返回dao中delete的处理结果
	}
	@Override
	public boolean update(int id,String name,int did){
		// TODO Auto-generated method stub
		return clbumDao.update(id,name,did);
	}
	
	@Override
	public int getCount(){
		return clbumDao.getCount();
	}
	@Override
	public List<Department> select() {
		// TODO Auto-generated method stub
		return departmentDao.selectAll();
	}



}
	
	

